
import sessionStorage from '@/utils/sessionStorage.js';
import cookie from '@/utils/cookie.js';
const user = {
  state: {
    // userInfo: sessionStorage.get('userInfo'),
    userInfo: cookie.readCookie('userInfo') ? JSON.parse(cookie.readCookie('userInfo')) : '',

  },

  mutations: {
    SET_INFO: (state, userInfo) => {
      state.userInfo = userInfo
      // sessionStorage.set('userInfo',userInfo);
      cookie.setCookie("userInfo", userInfo ? JSON.stringify(userInfo) : '');
    },
  },

  actions: {
    // 设置用户信息
    setUserInfo({ commit }, userInfo) {
      commit('SET_INFO', userInfo)
    },
  }
}

export default user
